{extend name="admin@public/basic" /}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/css/admin/public.css" media="all"/>
{/block}

{block name="cotent"}
<form class="layui-form">

    <!--顶部操作栏--开始-->
    <blockquote id="searchBlock" class="layui-elem-quote quoteBox">

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label-99admin">角色名称</label>
            <div class="layui-input-inline">
                <input type="text" id="title" class="layui-input" placeholder="请输入权限角色名称"/>
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label-99admin">角色状态</label>
            <div class="layui-input-inline">
                <select id="status" class="status" lay-filter="status">
                    <option value="">请选择角色状态</option>
                    {foreach $status as $vo}
                    <option value="{$vo.id|default=''}">{$vo.title|default=''}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label-99admin">创建时间</label>
            <div class="layui-input-inline">
                <input type="text" id="create_at" class="layui-input" placeholder="请选择创建时间">
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <a class="layui-btn" data-search="currentTableId">搜索</a>
        </div>

        {if auth("$thisClass/add")}
        <div class="layui-form-item layui-inline">
            <a class="layui-btn layui-btn-normal" data-open='{:url("$thisClass/add")}' data-title="添加文章">添加</a>
        </div>
        {/if}

        {if auth("$thisClass/del")}
        <div class="layui-form-item layui-inline">
            <a class="layui-btn layui-btn-danger layui-btn-normal" data-title="确定批量删除？" data-del-all='{:url("$thisClass/del")}' data-table-id="currentTableId">删除</a>
        </div>
        {/if}

    </blockquote>
    <!--顶部操作栏--结束-->

    <!--主表单渲染--开始-->
    <table id="currentTable" lay-filter="currentTable"></table>
    <!--主表单渲染--结束-->

    <!--表单模板绑定--开始-->
    <script type="text/html" id="checkStatus">
        <input type="checkbox" name="{{d.id}}" value="{{d.status}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="modifyStatus" {{ d.status== 1 ? 'checked' : '' }}>
    </script>
    <!--表单模板绑定--结束-->

    <!--表单操作栏--开始-->
    <script type="text/html" id="currentTableBar">

        {if auth("$thisClass/authorize")}
        <a class="layui-btn layui-btn-xs layui-btn-green" data-open='{:url("$thisClass/authorize")}?id={{d.id}}' data-title="角色授权">授权</a>
        {/if}

        {if auth("$thisClass/edit")}
        <a class="layui-btn layui-btn-xs" data-open='{:url("$thisClass/edit")}?id={{d.id}}' data-title="修改菜单信息">编辑</a>
        {/if}

        {if auth("$thisClass/del")}
        <a class="layui-btn layui-btn-xs layui-btn-danger" data-title="确定批量删除？" data-del='{:url("$thisClass/del")}?id={{d.id}}'>删除</a>
        {/if}

    </script>
    <!--表单操作栏--结束-->
</form>
{/block}

{block name="script"}
<script>

    /**
     * 生成表单
     */
    $.form.table('current', '{:url("$thisRequest")}?type=ajax', [[
        {type: "checkbox", fixed: "left", width: 50,},
        {field: 'sort', title: '排序', width: 100, edit: 'text', align: "center", sort: true},
        {field: 'title', title: '角色名称', minWidth: 200, align: 'center', sort: true},
        {field: 'remark', title: '备注信息', edit: 'text', minWidth: 200, align: "center", style: 'background-color: #009688; color: #fff;', sort: true},
        {field: 'create_at', title: '创建时间', align: 'center', sort: true},
        {field: 'status', title: '启用状态', width: 110, templet: '#checkStatus', unresize: true, align: "center"},
        /**{if auth("$thisClass/authorize") || auth("$thisClass/edit") || auth("$thisClass/del")}**/
        {title: '操作', minWidth: 110, templet: '#currentTableBar', fixed: "right", align: "center"},
        /**{/if}**/
    ]]);

    /**
     * 日期范围
     */
    $.laydate.range('create_at');

    /**
     * 监听字段值编辑
     */
    $.form.editField('currentTable', '{:url("$thisRequest")}');

    /**
     * 修改状态
     */
    $.form.switch('modifyStatus', '{:url("$thisClass/status")}');
</script>
{/block}
